import { IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum, IsArray } from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';
import { Type } from 'class-transformer';

export class BaseSettingsDto {
  @ApiProperty({ required: false, description: '孩子ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  childId?: number;

  @ApiProperty({ required: false, description: '类型，1为全天可用，2为全天禁用 3为禁用时段' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  type?: number;

  @ApiProperty({ required: false, description: '重复日期（如“周一,周二,周三”）' })
  @IsOptional()
  @IsString()
  repeatDays?: string;

  @ApiProperty({ required: false, description: '是否每日重复，0为否，1为是' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  isDaily?: number;

  @ApiProperty({ required: false, description: '禁用时段开始小时' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  startHour?: number;

  @ApiProperty({ required: false, description: '禁用时段开始分钟' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  startMinute?: number;

  @ApiProperty({ required: false, description: '禁用时段结束小时' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  endHour?: number;

  @ApiProperty({ required: false, description: '禁用时段结束分钟' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  endMinute?: number;

  @ApiProperty({ enum: CharEnum, required: false, description: '删除标志' })
  @IsOptional()
  @IsString()
  delFlag?: string;

  @ApiProperty({ required: false, description: '创建时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  createTime?: Array<string>;

  @ApiProperty({ required: false, description: '更新时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  updateTime?: Array<string>;
}

export class CreateSettingsDto extends OmitType(BaseSettingsDto, ['delFlag', 'createTime']) {}

export class UpdateSettingsDto extends OmitType(BaseSettingsDto, ['delFlag', 'createTime']) {}

export class QuerySettingsDto extends IntersectionType(BaseSettingsDto, PagingDto) {}

export class ListSettingsDto extends OmitType(BaseSettingsDto, ['delFlag', 'createTime', 'updateTime']) {}
